# coding: utf-8
from PySide6.QtCore import Qt
from PySide6.QtWidgets import QApplication, QHBoxLayout, QVBoxLayout, QWidget

from qelwidgets import ElIcon
from qelwidgets.components import (ElButton, ElPrimaryButton, ElSuccessPrimaryButton, ElWarningPrimaryButton,
                                         ElDangerPrimaryButton, ElInfoPrimaryButton, ElTransparentButton,
                                         ElToolButton, ElPrimaryToolButton, ElSuccessPrimaryToolButton,
                                         ElWarningPrimaryToolButton, ElDangerPrimaryToolButton, ElInfoPrimaryToolButton,
                                         ElTransparentToolButton)


class Demo(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.verticalLayout = QVBoxLayout(self)
        self.pushLayout = QHBoxLayout()
        self.toolLayout = QHBoxLayout()

        self.__initWidgets()

    def __initWidgets(self):
        self.setWindowTitle("Element Button Demo")

        self.__initLayout()

    def __initLayout(self):
        self.verticalLayout.setContentsMargins(10, 40, 10, 10)
        self.verticalLayout.setAlignment(Qt.AlignmentFlag.AlignTop)

        self.pushLayout.addWidget(ElButton(ElIcon.PartlyCloudy, "Default", self), 1)
        self.pushLayout.addWidget(ElPrimaryButton(ElIcon.PartlyCloudy, "Primary", self), 1)
        self.pushLayout.addWidget(ElSuccessPrimaryButton(ElIcon.PartlyCloudy, "Success", self), 1)
        self.pushLayout.addWidget(ElDangerPrimaryButton(ElIcon.PartlyCloudy, "Danger", self), 1)
        self.pushLayout.addWidget(ElWarningPrimaryButton(ElIcon.PartlyCloudy, "Warning", self), 1)
        self.pushLayout.addWidget(ElInfoPrimaryButton(ElIcon.PartlyCloudy, "Info", self), 1)
        self.pushLayout.addWidget(ElTransparentButton(ElIcon.PartlyCloudy, "Transparent", self), 1)
        self.verticalLayout.addLayout(self.pushLayout, 1)

        self.toolLayout.setAlignment(Qt.AlignmentFlag.AlignLeft)
        self.toolLayout.addWidget(ElToolButton(ElIcon.PartlyCloudy, self), 1)
        self.toolLayout.addWidget(ElPrimaryToolButton(ElIcon.PartlyCloudy, self), 1)
        self.toolLayout.addWidget(ElSuccessPrimaryToolButton(ElIcon.PartlyCloudy, self), 1)
        self.toolLayout.addWidget(ElDangerPrimaryToolButton(ElIcon.PartlyCloudy, self), 1)
        self.toolLayout.addWidget(ElWarningPrimaryToolButton(ElIcon.PartlyCloudy, self), 1)
        self.toolLayout.addWidget(ElInfoPrimaryToolButton(ElIcon.PartlyCloudy, self), 1)
        self.toolLayout.addWidget(ElTransparentToolButton(ElIcon.PartlyCloudy, self), 1)
        self.verticalLayout.addLayout(self.toolLayout, 1)


if __name__ == '__main__':
    import sys

    app = QApplication(sys.argv)
    demo = Demo()
    demo.setStyleSheet('Demo {background-color: #FFFFFF;}')
    demo.resize(1000, 800)
    demo.show()
    sys.exit(app.exec())
